package com.example.todofinally.adaoter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.todofinally.R;
import com.example.todofinally.sql.Data;

import java.util.ArrayList;
import java.util.List;

public class MainAdapter extends  RecyclerView.Adapter<MainAdapter.LinearViewHolder>{

    private Context mContext;
    private List<Data> mvalue=new ArrayList<>();
    public MainAdapter(Context context,List<Data> list){
        this.mvalue=list;
        this.mContext = context;
    }

    @NonNull
    @Override
    public LinearViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new LinearViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_content,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull LinearViewHolder holder, int position) {//绑定数据
        holder.start_time.setText(mvalue.get(position).startTime);
        /*holder.end_time.setText(mvalue.get(position).endTime);*/
        holder.edit_title.setText(mvalue.get(position).editTitle);
       // holder.end_time.setText(mvalue.get(position).id);
    }

    @Override
    public int getItemCount() {
        return mvalue.size();
    }

    class LinearViewHolder extends RecyclerView.ViewHolder {//绑定控件

        private TextView start_time,end_time,edit_title,event_time;
        private ImageView point;

        public LinearViewHolder(@NonNull View itemView) {
            super(itemView);
            start_time = itemView.findViewById(R.id.start_time);
            /*end_time = itemView.findViewById(R.id.end_time);*/
            edit_title = itemView.findViewById(R.id.edit_title);
           /* point = itemView.findViewById(R.id.point);
            event_time = itemView.findViewById(R.id.event_time);*/
        }
    }
}
